﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "ObjAutoInject.h"
#include <qvector.h>

#include "MEMSData.h"
#include "LogSaver.h"
#include "Device.h"



QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
//act
class ReadMEMSDataCodec_Client;
class TcpIOer;
class TcpCodec_Transmit;
class MCUCodec_SetInterval_MEMSData;
class UserRegisterCodec;
class DeviceInfoManager;
class UserInfoCodec;
//ui
class MemsAutoTestSoftware;
class DialogLogin;

class QTableWidget;
class QTableWidgetItem;
class MainWindow : public QMainWindow,public ObjAutoInject
{
  Q_OBJECT
private://property
  Ui::MainWindow *ui;
  QTableWidget *tableWidget_deviceList=Q_NULLPTR;

  QVector<QString> transmitResult;
private://dependency
  ReadMEMSDataCodec_Client* readMEMSDataCodec_Client=Q_NULLPTR;
  TcpIOer* tcpIOer=Q_NULLPTR;
  TcpCodec_Transmit* tcpCodec_Transmit=Q_NULLPTR;
  MCUCodec_SetInterval_MEMSData* mCUCodec_SetInterval_MEMSData=Q_NULLPTR;
  UserRegisterCodec* userRegisterCodec=Q_NULLPTR;
  DeviceInfoManager* deviceInfoManager=Q_NULLPTR;
  UserInfoCodec* userInfoCodec=Q_NULLPTR;
  //ui
  MemsAutoTestSoftware* memsAutoTestSoftware=Q_NULLPTR;
  DialogLogin* dialogLogin=Q_NULLPTR;

  LogSaver* logSaver=LogSaver::getLogSaver();
public:
  explicit MainWindow(QWidget *parent = nullptr);
  virtual ~MainWindow();
public slots:
  void slot_showData(int dataGroupIndex, QByteArray data);
protected:
  virtual void closeEvent(QCloseEvent * closeEvent) override;
  virtual void showEvent(QShowEvent * showEvent)override;
  virtual void hideEvent(QHideEvent * hideEvent)override;

private slots:
  void slot_MEMSData_readAll(QVector<MEMSData> list);
  void slot_showAllDevice();
  void slot_showResult(uchar result);
  void slot_logout();
private slots://pushButton
  void slot_pushButton_test();
  void slot_cellDoubleClicked(int row, int column);
private:
  void init();
  void showMessage(QString msg);
  QTableWidgetItem* makeTableWidgetItem(QString text);
public://geter and seter
  //act
  ReadMEMSDataCodec_Client* getReadMEMSDataCodec_Client();
  MainWindow* setReadMEMSDataCodec_Client(ReadMEMSDataCodec_Client* readMEMSDataCodec_Client);
  TcpIOer* getTcpIOer();
  MainWindow* setTcpIOer(TcpIOer* tcpIOer);
  TcpCodec_Transmit* getTcpCodec_Transmit()const;
  MainWindow* setTcpCodec_Transmit(TcpCodec_Transmit* const tcpCodec_Transmit);
  MCUCodec_SetInterval_MEMSData* setMCUCodec_SetInterval_MEMSData()const;
  MainWindow* setMCUCodec_SetInterval_MEMSData(MCUCodec_SetInterval_MEMSData* const mCUCodec_SetInterval_MEMSData);
  UserRegisterCodec* getUserRegisterCodec()const;
  MainWindow* setUserRegisterCodec(UserRegisterCodec*const userRegisterCodec);
  DeviceInfoManager* getDeviceInfoManager()const;
  MainWindow* setDeviceInfoManager(DeviceInfoManager* const deviceInfoManager);
  UserInfoCodec* getUserInfoCodec()const;
  MainWindow* setUserInfoCodec(UserInfoCodec*const userInfoCodec);
  //ui
  MemsAutoTestSoftware* getMemsAutoTestSoftware()const;
  MainWindow* setMemsAutoTestSoftware(MemsAutoTestSoftware*const memsAutoTestSoftware);
  DialogLogin* getDialogLogin()const;
  MainWindow* setDialogLogin(DialogLogin*const dialogLogin);
public:
  virtual void objectAutoInjection(QHash<QString, QObject *> *objMap)override;
};
#endif // MAINWINDOW_H
